UNAME=$(shell uname)
CFLAGS=-g -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26
LDFLAGS=-g -lfuse
GCC=g++
LD=g++
LIB=liborg_jfuse_Fuse.so
PLATFORM=$(shell javac Platform.java && java Platform)

ifeq ($(UNAME), Darwin)

LIB=liborg_jfuse_Fuse.jnilib
GCC=/Developer/usr/bin/g++-4.2
LD=/Developer/usr/bin/g++-4.2

#	-arch i386 
CFLAGS= \
	-D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26 -D__FreeBSD__=10 \
	-isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 \
	-I/usr/local/include \
	-I/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/

#	-arch i386 
LDFLAGS= \
	-isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 \
	-L/usr/local/lib -lfuse \
	-dynamiclib

endif

ifeq ($(UNAME), Linux)

LIB=liborg_jfuse_Fuse.so
CFLAGS= \
	-g \
	-shared -fPIC \
	-D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26 \
	-I/usr/lib/jvm/java-6-sun-1.6.0.22/include/linux/ \
	-I/usr/lib/jvm/java-6-sun-1.6.0.22/include/

LDFLAGS= \
	-g \
	-shared \
	-lfuse

endif


all: $(LIB)
	cp -a $(LIB) ../build/bin/org/jfuse/$(PLATFORM)_$(LIB)

$(LIB): org_jfuse_Fuse.cpp
	javah -classpath ../build/bin/ -jni org.jfuse.Fuse
	$(GCC) $(CFLAGS) -c -o org_jfuse_Fuse.o org_jfuse_Fuse.cpp
	$(LD) $(LDFLAGS) org_jfuse_Fuse.o -o $(LIB)

